package trading.ctm.yunjing.module.main.fragment

import android.content.Intent
import android.os.Bundle
import cc.vv.baselibrary.fragment.BaseFragment
import cc.vv.baselibrary.view.pulltorefresh.PullToRefreshBase
import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.android.synthetic.main.layout_home_short_cut.*
import kotlinx.android.synthetic.main.layout_home_title.*
import trading.ctm.yunjing.R
import trading.ctm.yunjing.module.main.activity.FlickingActivity
import trading.ctm.yunjing.module.main.activity.SearchActivity
import trading.ctm.yunjing.module.message.activity.MessageInformActivity
import trading.ctm.yunjing.module.mine.activity.*

/**
 * 首页
 */
class HomeFragment : BaseFragment() {

    override fun initLayoutRes(): Int {
        return R.layout.fragment_home
    }

    override fun initData(bundle: Bundle?) {
        super.initData(bundle)
    }

    override fun initAction(bundle: Bundle?) {
        super.initAction(bundle)

        //二维码扫描
        iv_fh_zxing.setOnClickListener {
            startActivity(Intent(activity, FlickingActivity::class.java))
        }

        //搜索
        ll_fh_search.setOnClickListener {
            startActivity(Intent(activity, SearchActivity::class.java))
        }

        //消息
        iv_fh_message.setOnClickListener {
            startActivity(Intent(activity, MessageInformActivity::class.java))
        }
        var data = arrayListOf("http://img15.3lian.com/2015/f1/90/d/106.jpg",
                "http://pic34.nipic.com/20131016/7487939_145711674162_2.jpg",
                "http://attach.bbs.miui.com/forum/201312/18/204803vxvoqod4hohod8dn.jpg",
                "http://pic29.nipic.com/20130520/7487939_205025481178_2.jpg")

        //广告轮播
        ibv_fh_ad_icon.initWHPercentage(210, 375, -1)
        ibv_fh_ad_icon.initImgData(data) {
            imgPath, position ->
        }
        ibv_fh_ad_icon.initIndicatorView(R.mipmap.icon_ctm_no_selector,R.mipmap.icon_ctm_selector,8,8)


        var list = arrayListOf("aaaaaaaaaaa",
                "bbbbbbbbbbbbb",
                "cccccccccccccccc")
        mv_fh_marqueeview.startWithList(list)

        //申请入库
        ll_hsc_apply_lib.setOnClickListener {
            startActivity(Intent(activity, IntoLibApplyActivity::class.java))

        }
        //我的货物
        ll_hsc_mine_cargo.setOnClickListener {
            startActivity(Intent(activity, MineCargoActivity::class.java))
        }
        //发布供应
        ll_hsc_publish_supply.setOnClickListener {
            startActivity(Intent(activity, PublishSupplyActivity::class.java))
        }
        //发布求购
        ll_hsc_publish_buy.setOnClickListener {
            startActivity(Intent(activity, PublishPurchaseActivity::class.java))
        }
        //发起拍卖
        ll_hsc_sponsor_auction.setOnClickListener {
            startActivity(Intent(activity, SponsorAuctionActivity::class.java))
        }

        val mData = arrayListOf("111111111111111111", "111111111111111111", "111111111111111111", "111111111111111111")
        //拍卖信息
        ll_hav_action.initData(mData)

        ll_hiv_information.initData(mData)
        //资讯信息
        prnv_fh_information.mode = PullToRefreshBase.Mode.PULL_FROM_END
        prnv_fh_information.setOnRefreshListener {
            mData.add("llllllll")
            ll_hiv_information.initData(mData)
            prnv_fh_information.onRefreshComplete()
        }

    }

}